const express = require('express');
const fs = require('fs');

// 创建服务  
const server = express();


// server.use('/aaa',(req,res)=>{
//     res.send('hello world')
// })


// server.use('/bbb',(req,res)=>{
//    fs.readFile('C:\\www\\2302\\day33\\复习\\index.html','utf-8',(err,data)=>{
//         res.send(data);
//    })
// })


// 一种是 静态资源  

// 一种是从数据库中提取并且返回 



// /static   到fuxiang中找对应的静态文件  

// /static/css/index.css     /fuxiang/css/index.css
// /static/js/index.js    /fuxiang/js/index.js

// /static/views/myindex.html    /fuxiang/views/myindex.html

// express.static('路径')
server.use('/static',express.static('C:\\www\\2302\\day33\\复习\\fuxiang\\'))



server.use('/api/goods/list',(req,res)=>
    res.send({
        code:1,
        message:'获取列表成功',
        data:[{name:'张三'},{name:'张三1'},{name:'张三2'}]
    })
);

server.use('/api/goods/info',(req,res)=>
    res.send({
        code:1,
        message:'获取信息成功',
        data:[{name:'张三'},{name:'张三1'},{name:'张三2'}]
    })
);


server.use('/api/users/register',(req,res)=>
    res.send({
        code:1,
        message:'注册成功',
        data:[{name:'张三'},{name:'张三1'},{name:'张三2'}]
    })
);

server.use('/api/users/login',(req,res)=>
    res.send({
        code:1,
        message:'登录成功',
        data:[{name:'张三'},{name:'张三1'},{name:'张三2'}]
    })
);
// 启动服务 监听端口 

server.listen(8080,()=>{
    console.log('访问成功');
})